// pages/goods/survey/product_details/index.js
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        parameter: {
            'navbar': '1',
            'return': '1',
            'title': '商品铺店详情',
            'color': true,
            'class': false
        },
        isNav: 1,
        value: "",
        pic: "https://pic.localhost.com/",
        executorUserId: "",
        isSearchList: true
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        this.setData({
            goodsid: options.goodsid,
            goodsname: options.goodsname,
            status: options.status
        })
        wx.getStorage({
            key: 'userInfo',
            success(res) {
                that.setData({
                    executorUserId: res.data.id,
                })
                that.store()
                that.goods()
            }
        })

    },
    //店铺信息
    store(e,isNav){
        var that = this,
        isNav = that.data.isNav
        try {
            that.data.value = e.detail.value
        } catch (e) {}
        app.baseGet(app.U({
            m: 'api',
            c: 'task',
            a: 'workerBeeInfo/findWorderBeeGoodsDeaptDetails/',
            q: {
                goodsId: that.data.goodsid,
                dealerName: that.data.value,
                status: isNav == undefined || isNav == 1 ? "" : isNav,
                executorUserId: that.data.executorUserId
            }
        }), res => {
            that.setData({
                storeinfo: res.data
            })
        }, (res) => {})
    },
    //商品信息
    goods() {
        var that = this;
        app.baseGet(app.U({
            m: 'api',
            c: 'task',
            a: 'workerBeeInfo/findWorkerBeeStatusSum/',
            q: {
                goodsId: that.data.goodsid,
                goodsName: that.data.goodsname,
                status: that.data.status == 5 ? 5 : 15,
                executorUserId: that.data.executorUserId
            }
        }), res => {
            that.setData({
                goodsinfo: res.data[0].goodsInfo[0]
            })
        }, (res) => {})
    },
    stateTop(e) {
        this.setData({
            isNav: e.currentTarget.dataset.item,
            storeinfo: ""
        })
        this.store(this.data.isNav)
    },
})